package com.mdlib.droid.common;

import android.content.Context;

import com.lzy.okgo.model.HttpHeaders;
import com.mdlib.droid.AppContext;
import com.mdlib.droid.model.AccountModel;
import com.mdlib.droid.util.language.LanguageType;
import com.mdlib.droid.util.language.MultiLanguageUtil;

/**
 * Created by apple on 16/12/21.
 */

public class OkHead {


    //获取未登陆的公共头
    public static HttpHeaders getCommonHead(Context context) {

        int savedLanguageType = MultiLanguageUtil.getInstance().getLanguageType();
        String langType = "";
        if (savedLanguageType == LanguageType.LANGUAGE_CHINESE_SIMPLIFIED) {
            langType="cn";
        } else if (savedLanguageType == LanguageType.LANGUAGE_EN) {
            langType="en";
        }else{
            langType="cn";
        }

        //公共请求头
        HttpHeaders headers = new HttpHeaders();
        headers.put("appcode", AppContext.getInstance().getPackageName());
        headers.put("platform", "android");
        headers.put("token", "");
        headers.put("version", AppContext.getInstance().getVersion());
        headers.put("lang", langType);

        return headers;

    }

    //获取登陆的公共头
    public static HttpHeaders getCommonHeadToken(Context context) {

        int savedLanguageType = MultiLanguageUtil.getInstance().getLanguageType();
        String langType = "";
        if (savedLanguageType == LanguageType.LANGUAGE_CHINESE_SIMPLIFIED) {
            langType="cn";
        } else if (savedLanguageType == LanguageType.LANGUAGE_EN) {
            langType="en";
        }else{
            langType="cn";
        }
        //公共请求头
        HttpHeaders headers = new HttpHeaders();
        headers.put("appcode", AppContext.getInstance().getPackageName());
        headers.put("platform", "android");
        headers.put("token", AccountModel.getInstance().getToken());
        headers.put("version", AppContext.getInstance().getVersion());
        headers.put("lang", langType);

        return headers;

    }


}
